package com.haima.sage.bigdata.api.vo.param.agg;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.haima.sage.bigdata.api.common.NameUtils;

public enum AggType {
    Max("max"), Min("min"), Sum("sum"), Avg("avg"), Count("count"), CountDistinct("countdistinct");

    //自定义字段
    private String value;

    //构造方法
    AggType(String value) {
        this.value = value;
    }

    @JsonValue
    public String getValue() {
        return value;
    }

    @JsonCreator
    public static AggType newInstance(String type) {
        type = NameUtils.trans(type);
        for (AggType item : values()) {
            String tmp = NameUtils.trans(item.getValue());
            if (tmp.equals(type)) {
                return item;
            }
        }
        return null;
    }
}
